【点云surface】Poisson表面重建

您所在的位置:网站首页 MATLAB 点云曲面重建 【点云surface】Poisson表面重建

【点云surface】Poisson表面重建

2023-12-02 00:22| 来源: 网络整理| 查看: 265

1 介绍

Poisson表面重建算法是一种用于从点云数据生成平滑曲面模型的算法。它基于Michael Kazhdan等人在2006年发表的论文《Poisson surface reconstruction》。该算法通过将点云数据转换为体素表示,并利用Poisson方程来重建曲面。

该算法的基本原理是将点云数据转换为体素表示,然后通过求解Poisson方程来重建曲面。Poisson方程是一个偏微分方程,它描述了一个函数的Laplace算子(二阶导数)与该函数的散度之间的关系。通过求解Poisson方程,可以得到一个平滑的曲面模型,该模型与原始点云数据尽可能匹配。

在PCL(点云库)中,Poisson表面重建算法有以下一些参数可以调整:

setDepth:体素深度。该参数定义了体素表示的深度级别,影响生成的体素分辨率和曲面细节。较高的深度级别会导致更高的分辨率和更准确的曲面重建,但也会增加计算时间和内存消耗。

setscale:体素缩放因子。该参数定义了体素表示的缩放比例,影响生成的体素分辨率和曲面细节。较小的缩放因子会导致更高的分辨率和更准确的曲面重建,但也会增加计算时间和内存消耗。

setSolverDivide:求解器分割数。该参数定义了求解器在求解Poisson方程时的分割数。较大的分割数可以提高求解的准确性和稳定性,但也会增加计算时间和内存消耗。

setIsoDivide:等值面分割数。该参数定义了生成等值面的分割数。较大的分割数可以提高等值面的平滑度和细节,但也会增加计算时间和内存消耗。

setConfidence:置信度。该参数定义了曲面重建中点云数据的置信度。较高的置信度会使算法更加关注点云数据,而较低的置信度会使算法更加关注平滑曲面的生成。

setOutputPolygons:输出多边形。该参数定义了是否输出多边形表示的曲面模型。如果设置为true,则算法将输出多边形表示的曲面模型;如果设置为false,则算法将输出三角网格表示的曲面模型。

一般使用默认参数即可

2 效果 原始数据

3 代码 #include #include #include #include #include #include #include int main() { pcl::PointCloud::Ptr cloud(new pcl::PointCloud); pcl::PCLPointCloud2 cloud2; pcl::io::loadPCDFile("/home/lrj/work/pointCloudData/bun0.pcd",cloud2); pcl::fromPCLPointCloud2(cloud2,*cloud); // 估计点云的法向量 pcl::search::KdTree::Ptr tree(new pcl::search::KdTree); tree->setInputCloud(cloud); pcl::NormalEstimation ne; ne.setInputCloud(cloud); ne.setSearchMethod(tree); ne.setKSearch(20);//最近邻搜索参数 pcl::PointCloud::Ptr normals(new pcl::PointCloud); ne.compute(*normals); // 将法线添加到点云数据集中 pcl::PointCloud::Ptr cloudWithNormals(new pcl::PointCloud); pcl::concatenateFields(*cloud, *normals, *cloudWithNormals); // 创建Poisson重建对象 pcl::Poisson poisson; poisson.setInputCloud(cloudWithNormals); // 执行Poisson重建 pcl::PolygonMesh mesh; poisson.reconstruct(mesh); boost::shared_ptr viewer(new pcl::visualization::PCLVisualizer("Smoothed Point Cloud Viewer")); viewer->setBackgroundColor(0.05, 0.05, 0.05,0); viewer->addPolygonMesh(mesh, "mesh"); // 将Poisson曲面的网格数据mesh添加到PCL的可视化工具 viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, 0.5, 0.5, 0.5, "mesh");//设置网格颜色为会灰色 viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, 0.8, "mesh");// 设置网格透明度为0.8,0为完全透明 while(!viewer->wasStopped()) { viewer->spinOnce(); } }



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3